﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Net;

namespace CYTS.Aoyou.Framework.Context
{
    public class WebContext : ICloneable
    {
        public WebContext()
        {
            this.UniqueID = Guid.NewGuid();
            this.UserID = 0;
            this.SessionID = string.Empty;
            this.Rights = new List<string>();
            //this.Items = new Hashtable();
            //this.Items.Add("ContextID", this.UniqueID);
            this.ServerAddress = string.Empty;
            this.ClientAddress = string.Empty;
            this.ServerName = string.Empty;
            this.PerformanceEntity = null;
            this.CallTime = DateTime.Now;
            this.ServiceName = string.Empty;
        }

        ///// <summary>
        ///// 上下文数据
        ///// </summary>
        //public Hashtable Items
        //{
        //    get;
        //    set;
        //}

        /// <summary>
        /// 上下文ID
        /// </summary>
        public Guid UniqueID
        {
            get;
            set;
        }

        /// <summary>
        /// 用户ID
        /// </summary>
        public int UserID
        {
            get;
            set;
        }

        /// <summary>
        /// 用户真实名
        /// </summary>
        public string UserRealName
        {
            get;
            set;
        }

        /// <summary>
        /// 用户登录名
        /// </summary>
        public string UserLoginName
        {
            get;
            set;
        }

        /// <summary>
        /// SessionID
        /// </summary>
        public string SessionID
        {
            get;
            set;
        }

        /// <summary>
        /// 用户权限集合
        /// </summary>
        public List<string> Rights
        {
            get;
            set;
        }


        public string ServerAddress
        {
            get;
            set;
        }

        public string ClientAddress
        {
            get;
            set;
        }

        public string ServerName
        {
            get;
            set;
        }

        public PerformanceBaseEntity PerformanceEntity 
        { 
            get; 
            set; 
        }

        public DateTime CallTime 
        { 
            get; 
            set; 
        }

        public string ServiceName
        {
            get;
            set;
        }

        public object Clone()
        {
            return new WebContext()
            {
                //Items = this.Items,
                Rights = this.Rights,
                SessionID = this.SessionID,
                UniqueID = this.UniqueID,
                UserID = this.UserID,
                UserRealName = this.UserRealName,
                UserLoginName = this.UserLoginName,
                ClientAddress = this.ClientAddress,
                ServerAddress = this.ServerAddress,
                ServerName = this.ServerName,
                CallTime = this.CallTime,
                PerformanceEntity = this.PerformanceEntity,
                ServiceName = this.ServiceName
            };
        }
    }
}
